<!DOCTYPE html> 
<html> 
<head> 
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>2019年考研倒计时</title> 
<style>
        body {
            -webkit-font-smoothing: antialiased;
            font-family: Helvetica Neue, Helvetica, Hiragino Sans GB, Microsoft YaHei, Arial, sans-serif;
            background-image: url('bg1.jpg');
            font-size: 85%;
            margin: 0;
        }
        
        h2 {
            font-size: 220%;
            font-weight: 400;
        }
        
        .content {
            position: absolute;
            width: 100%;
            top: 40%;
            transform: translate(0, -50%);
            text-align: center;
        }
        
        .timer {
            font-size: 180%;
            line-height: 1.5;
            margin: 1em 0;
        }
        
        .timer b {
            color: rgb(0,0,225);
        }
</style>

</head> 
<body onload="leftTimer()"> 
 
<div class="content">
        <h2>距2019年考研仅剩</h2>
        <div class="timer">
            <b id="d"></b>天<b id="h"></b>小时<b id="m"></b>分<b id="s"></b>秒
        </div>
    </div>
</body> 
</html>
<script language="javascript" type="text/javascript"> 
function leftTimer(year,month,day,hour,minute,second){
    var leftTime = (new Date(year,month-1,day,hour,minute,second)) - (new Date()); //计算剩余的毫秒数
    var days = parseInt(leftTime / 1000 / 60 / 60 / 24  , 10); //计算剩余的天数
    var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //计算剩余的小时
    var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟
    var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数
    days = checkTime(days);
    hours = checkTime(hours);
    minutes = checkTime(minutes);
    seconds = checkTime(seconds);
    setInterval("leftTimer(2018,12,22,08,00,00)",1000);
    document.getElementById('d').innerHTML =days;
    document.getElementById('h').innerHTML =hours;
    document.getElementById('m').innerHTML =minutes;
    document.getElementById('s').innerHTML =seconds; 
}
function checkTime(i){ //将0-9的数字前面加上0，例1变为01
    if(i<10)
    {
        i = "0" + i;
    }
    return i;
}
 
</script>